package com.sui.bigdata.sml.web.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @author songhaicheng
 * @date 2019/11/5 10:00
 * @description
 * @reviewer
 */
@Data
@Accessors(chain = true)
public class NodeResultDTO {

    private Long id;
    private Long nodeId;
    private String curParams;
    private String result;
    private List<String> fieldNames;
    private List<List<String>> values;
    private String createTime;

    /**
     * 把 result 字段拆解成表头、表体两部分
     */
    public void parseResult() {
        List<List<String>> records = JSON.parseObject(this.result, new TypeReference<List<List<String>>>(){});
        this.fieldNames = records.remove(0);
        this.values = records;
        this.result = null;
    }

}
